package cn.edu.lingnan.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.lingnan.dao.StudentDAO;
import cn.edu.lingnan.dto.Student;

public class RegisterServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
			throws ServletException, IOException {
		//1
		String sid=req.getParameter("sid");
		String username=req.getParameter("username");
		String password=req.getParameter("password1");
		int ssuper=Integer.parseInt(req.getParameter("ssuper"));
		Student s=new Student();
		s.setsId(sid);
		s.setsName(username);
		s.setsPassword(password);
		s.setsSuper(ssuper);
		StudentDAO sd=new StudentDAO();
		int flag=sd.insert(s);
		if(flag==1)
			resp.sendRedirect(req.getContextPath()+"/index.html");
		else
			resp.sendRedirect(req.getContextPath()+"/register.html");
		
	}

}
